
#CROSS=

CC=$(CROSS)gcc
CPP=$(CROSS)g++
STRIP=$(CROSS)strip

TARGET_INSTALL_DIR=./../../target

BIN= $(TARGET_INSTALL_DIR)/lib/libgroupsock.so

.PHONY: all after-all

all:$(BIN) after-all

after-all :
	rm -rf *.o

INCLUDE = -I ./include/ -I../UsageEnvironment/include -I ./
CXXFLAGS =-O2 -DXLOCALE_NOT_USED=1 -DSOCKLEN_T=socklen_t -DNO_SSTREAM=1 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -Wall -DBSD=1

TGT = $(SRC_C:.c=.o) $(SRC_CPP:.cpp=.o)

SRC_C = $(wildcard *.c)
SRC_CPP = $(wildcard *.cpp)

SRC_C = $(wildcard *.c)
SRC_CPP = $(wildcard *.cpp)


%.o:%.c
	$(CC) -c $? -s -O2 $(INCLUDE) $(CXXFLAGS) -fPIC -o ./$@ 
%.o:%.cpp
	$(CPP) -c $? -s -O2 $(INCLUDE) $(CXXFLAGS) -fPIC -o ./$@ 

$(BIN): $(TGT)
	$(CPP) $(CXXFLAGS) -Wall -fPIC -s -shared -O2 $(LDFLAGS) ./*.o -o $(BIN) -lrt
	$(STRIP) $(BIN)
	cp -rf include/* $(TARGET_INSTALL_DIR)/include

clean :
	rm -rf *.o *.so

